package org.xenon.vote.model.pojo.po;

import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 密码恢复口令
 */
public class Rec {
    /**
     * 口令
     */
    @NotNull(message = "hash.null")
    @NotBlank(message = "hash.blank")
    String token;

    /**
     * 账号邮箱
     */
    @NotNull(message = "mail.null")
    @NotBlank(message = "mail.blank")
    @Email(message = "mail.format")
    @Max(value = 128)
    String mail;

    /**
     * 想要恢复的密码
     */
    @NotNull(message = "password.null")
    @NotBlank(message = "password.blank")
    @Max(value = 32)
    String passwd;

    /**
     * 创建时间
     */
    @NotNull(message = "time.null")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birth;

    /**
     * 有效时间(秒)
     */
    @NotNull
    private int age;


    public Rec(@NotNull(message = "hash.null")
               @NotBlank(message = "hash.blank") String token,
               @NotNull(message = "mail.null")
               @NotBlank(message = "mail.blank")
               @Email(message = "mail.format")
               @Max(value = 128) String mail,
               @NotNull(message = "password.null")
               @NotBlank(message = "password.blank")
               @Max(value = 32) String passwd,
               @NotNull(message = "time.null") Date birth,
               @NotNull int age) {
        this.token = token;
        this.mail = mail;
        this.passwd = passwd;
        this.birth = birth;
        this.age = age;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
